package com.ruoyi.web.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.BusinessUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.service.BusinessUserService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: 何建文
 * @create: 2022-05-15 20:15
 * @description:
 **/
@RestController
@RequestMapping("/dynamic/datasource")
public class DynamicDataSourceTestController {

    @Autowired
    private BusinessUserService businessUserService;

    @Autowired
    private ISysUserService sysUserService;

    @GetMapping("/listUser")
    public AjaxResult listUser(int datasourceType) {
        if (datasourceType == 0) {
            SysUser sysUser = sysUserService.selectUserById(1L);
            return AjaxResult.success(sysUser);
        }

        List<BusinessUser> userList = businessUserService.selectAll();
        return AjaxResult.success(userList);
    }
}
